package com.dao.impl;

// Generated 15 f�vr. 2013 15:56:26 by Hibernate Tools 4.0.0

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.dao.InterventionTypeDao;
import com.model.InterventionType;

/**
 * Home object for domain model class InterventionType.
 * @see com.model.InterventionType
 * @author Hibernate Tools
 */
@Repository
public class InterventionTypeHome implements InterventionTypeDao{

	private static final Logger log = Logger.getLogger(InterventionTypeHome.class);

	@PersistenceContext
	private EntityManager entityManager;

	public void create(InterventionType transientInstance) {
		log.debug("persisting InterventionType instance");
		try {
			entityManager.persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void delete(InterventionType persistentInstance) {
		log.debug("removing InterventionType instance");
		try {
			entityManager.remove(persistentInstance);
			log.debug("remove successful");
		} catch (RuntimeException re) {
			log.error("remove failed", re);
			throw re;
		}
	}

	public InterventionType update(InterventionType detachedInstance) {
		log.debug("merging InterventionType instance");
		try {
			InterventionType result = entityManager.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public InterventionType findById(int id) {
		log.debug("getting InterventionType instance with id: " + id);
		try {
			InterventionType instance = entityManager.find(
					InterventionType.class, id);
			log.debug("get successful");
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}
